{include file="common/_meta" /}
<title></title>
</head>

<body>
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span>订单管理
        <span class="c-gray en">&gt;</span> 订单列表
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"
            title="刷新">
            <i class="Hui-iconfont">&#xe68f;</i>
        </a>
    </nav>
    <div class="page-container">
        <div class="text-c">
            <form class="Huiform" method="get" action="">
                状态：
                <span class="select-box inline">
                    <select name="status" class="select">
                        <option value="">全部</option>
                        <option value="0">待发货</option>
                        <option value="1">待收货</option>
                        <option value="2">已完成</option>
                    </select>
                </span>
                日期范围：
                <input type="text" class="input-text Wdate" name="start" id="countTimestart" onfocus="selecttime(1)" value="" size="17" class="date"
                    readonly style="width:140px;"> -
                <input type="text" class="input-text Wdate" name="end" id="countTimeend" onfocus="selecttime(2)" value="" size="17" class="date"
                    readonly style="width:140px;">
                
                <input type="text" class="input-text hidden" style="width:250px" placeholder="" id="" name="is_pay" value="1">
                <!-- <input type="text" class="input-text" style="width:250px" placeholder="" id="" name="keywords" value="{$Think.get.keywords|default=''}"> -->
                <button type="submit" class="btn btn-success radius" id="" name="">
                    <i class="Hui-iconfont">&#xe665;</i> 搜索</button>
            </form>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="r">共有数据：
                <strong>{$list->total()}</strong> 条</span>
        </div>
        <div class="mt-20">
            <table class="table table-border  table-hover table-bg table-sort">
                <thead>
                    <tr class="text-c">
                        <th width="25">
                            <input type="checkbox" name="" value="">
                        </th>
                        <th>订单编号</th>
                        <th>买家账号</th>
                        <th>商家信息</th>
                        <th>订单金额</th>
                        <th>订单详情</th>
                        <th>支付状态</th>
                        <!-- <th>更新时间</th> -->
                        <th>下单时间</th>
                        <!-- <th>订单备注</th> -->
                        <th>订单状态</th>
                        <th>系统操作</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    {volist name="list" id="vo" key="k"}
                    <tr class="text-c">
                        <td>
                            <input type="checkbox" value="1" name="">
                        </td>
                        <td>{$vo.out_trade_no}</td>
                        <td>{$vo.buyer.name}
                            <br/>{$vo.buyer.tel}</td>
                        <td>{$vo.shop.name}
                            <br/>{$vo.shop.tel}</td>
                        <td>{$vo.order_money}</td>
                        <td><a href="javascript:;" onclick="showDetail({$vo.id})">[点击查看]</a></td>

                        {if condition="$vo['is_pay'] eq 1"}
                        <td>已支付</td>
                        {else/}
                        <td style="color: red;">
                           未支付
                        </td>
                        {/if}
                        <!-- <td >{$vo.update_time}</td> -->
                        <td>{$vo.create_time}</td>
                        <!-- <td>{$vo.note}</td> -->
                        <td class="td-status">
                            {if condition="$vo.is_pay eq 1"}
                                 {switch name="$vo['status']" } 
                                 {case value="0" break="0或1"}<span class="label label-default radius">待发货</span>{/case} 
                                 {case value="1"}<span class="label label-secondary radius">待收货</span>{/case} 
                                 {case value="2"}<span class="label label-success radius">已完成</span>{/case}
                                 {/switch}
                            {else/}
                                <span class="label label-danger radius">待支付</span>
                            {/if}
                        </td>
                        <td class="td-manage" width="10%">
                            {if condition="$vo['status'] eq 1"}
                                <a style="text-decoration:none" onClick="confirm(this,{$vo.id})" href="javascript:;" title="确认收货">
                                    <i class="Hui-iconfont">&#xe6a7;</i>
                                </a>
                            {elseif condition="$vo['status'] eq 0"}
                                <a style="text-decoration:none" onClick="reject(this,{$vo.id})" href="javascript:;" title="驳回订单">
                                    <i class="Hui-iconfont">&#xe6a6;</i>
                                </a>
                            {else/}
                            {/if}
                        </td>
                    </tr>
                    {/volist}
                </tbody>
            </table>
            <div class="pages" style="margin:20px;float: right; ">{$list->render()}</div>
        </div>
    </div>
    {include file="common/_footer" /}
    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript" src="/static/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
    <script type="text/javascript">
        $('select[name="status"]').val("{$Request.get.status}");
        function selecttime(flag) {
            if (flag == 1) {
                var endTime = $("#countTimeend").val();
                if (endTime != "") {
                    WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm', maxDate: endTime })
                } else {
                    WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm' })
                }
            } else {
                var startTime = $("#countTimestart").val();
                if (startTime != "") {
                    WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm', minDate: startTime })
                } else {
                    WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm' })
                }
            }
        }

        function showDetail(id) {
            var url = "{:url('Mall/orderDetail')}?id=" + id;
            layer_show('订单详情', url);
        }

        function confirm(obj, id) {
            // 发货
           layer.confirm('代替玩家确认收货吗', {btn: ['确认','取消'] //按钮
            }, function(){
                $.post("{:url('Mall/orderList')}?act=confirm", {id: id}).success(function (data) {
                    layer.msg(data.msg);
                    if (data.code) {
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已完成</span>');
                        $(obj).remove();
                    }
                });
            });
        }

        function reject(obj, id) {
            // 发货
           layer.confirm('代替商家取消订单吗', {btn: ['确认','取消'] //按钮
            }, function(){
                $.post("{:url('Mall/orderList')}?act=cancle", {id: id}).success(function (data) {
                    layer.msg(data.msg);
                    if (data.code) {
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">已驳回</span>');
                        $(obj).remove();
                    }
                });
            });
        }

    </script>
</body>

</html>